package graphic.complex;

import graphic.primitives.general.Circle;
import graphic.primitives.general.GraphicObject;
import graphic.primitives.general.IGraphicObject;
import java.awt.Color;
import java.util.Random;

/**
 *
 * @author Tomas Zima
 */
public class Person extends GraphicObject implements IGraphicObject
{
	public Person(int x, int y)
	{
		super(x, y);
	}

	@Override
	public void redraw()
	{
		float rot = mainWindow.getRotationAngle();
		
		mainWindow.setRotationCenter(x + 15, y - 50);
		mainWindow.setRotationAngle(legAngleLeft);
		
		// Shoes (front)
		mainWindow.setColor(new Color(0.1f, 0.1f, 0.1f));
		for (int i = 0; i < 21; i++)
		{
			mainWindow.line(x + i, y, x + i, y - 10);
		}
		
		// Trousers (front)
		mainWindow.setColor(new Color(0.0f, 0.0f, 0.3f));
		for (int i = 0; i < 40; i++)
		{
			mainWindow.line(x + 10, y - 10 - i, x + 20, y - 10 - i);
		}

		mainWindow.setRotationAngle(legAngleRight);
		
		// Shoes (back)
		mainWindow.setColor(new Color(0.1f, 0.1f, 0.1f));
		for (int i = 0; i < 21; i++)
		{
			mainWindow.line(x + i, y, x + i, y - 10);
		}
		
		// Trousers (back)
		mainWindow.setColor(new Color(0.0f, 0.0f, 0.3f));
		for (int i = 0; i < 40; i++)
		{
			mainWindow.line(x + 10, y - 10 - i, x + 20, y - 10 - i);
		}
		
		mainWindow.setRotationAngle(rot);		
		
		// Body
		mainWindow.setColor(new Color(0.61f, 0.4f, 0.12f));
		for (int i = 0; i < 50; i++)
		{
			mainWindow.line(x, y - 50 - i, x + 30, y - 50 - i);
		}
		
		// Neck
		for (int i = 0; i < 10; i++)
		{
			mainWindow.line(x + 10, y - 100 - i, x + 20, y - 100 - i);
		}
		
		// Head
		mainWindow.setColor(new Color(0.96f, 0.87f, 0.70f));
		for (int i = 0; i < 10; i++)
		{
			new Circle(x + 15, y - 120, 10 - i).redraw();
		}
		
		// Arm
		mainWindow.setColor(Color.BLACK);
		mainWindow.line(x + 10, y - 90, x + 10, y - 60);
		mainWindow.line(x + 20, y - 90, x + 20, y - 60);
		mainWindow.line(x + 10, y - 60, x + 20, y - 60);
	}
	
	protected void setLegAngleLeft(float angle)
	{
		this.legAngleLeft = angle;
	}
	
	protected void setLegAngleRight(float angle)
	{
		this.legAngleRight = angle;
	}
	
	private float legAngleLeft	= 30;
	private float legAngleRight	= 0;
}
